<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page errorPage="error.jsp" %>

<c:set var="notPayedCarRequests"
		value="${sessionScope.carRentAppModel.getAllNotPayedCarRequests()}" />
<c:set var="cancelledCarRequests"
		value="${sessionScope.carRentAppModel.getAllCancelledRequests()}" />
<c:set var="payedCarRequests"
		value="${sessionScope.carRentAppModel.getAllPayedCarRequests()}" />

<html>
<head>
<title>Car Rent 1.0</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<style type="text/css">
body,table,hr {
	color: black;
	background: silver;
	font-family: Verdana, sans-serif;
	font-size: x-small;
}
</style>
</head>
<body>

	<h2>Car Rent 1.0</h2>
	<a href="defaultAction.perform">Go to Start</a>
	<fieldset>
		<legend>
			<b>Not payed car requests</b>
		</legend>
		<table border="below" cellpadding="10" cellspacing="0" width="100%">
			<tr>
				<th align="center">User Name</th>
				<th align="center">Name</th>
				<th align="center">Passport</th>
				<th align="center">Car</th>
				<th align="center">Rent Duration</th>
				<th colspan="2" align="center">Action</th>
			</tr>
			<c:forEach items="${notPayedCarRequests}" var="notPayedCarRequest">
				<c:set var="car" value="${notPayedCarRequest.getCar()}" />
				<c:set var="user" value="${notPayedCarRequest.getUser()}" />
				<tr>
					<td align="center"><c:out value="${user.getLogin()}" /></td>
					<td align="center"><c:out
							value="${notPayedCarRequest.getName()}" /></td>
					<td align="center"><c:out
							value="${notPayedCarRequest.getPassport()}" /></td>
					<td align="center"><c:out
							value="${car.getManufacturer()} ${car.getModel()} ${car.getNumber()}" /></td>
					<td align="center"><c:out
							value="${notPayedCarRequest.getRentDuration()}" /></td>
					<td align="center">
						<form method="post" action="approveRequestAction.perform">
							<input type="hidden" name="id"
								value="${notPayedCarRequest.getID()}"> <input
								type="hidden" name="billPurpose" value="rent payment"> <input
								type="submit" name="approve" value="approve">
						</form>
					</td>
					<td align="center"><form method="post"
							action="cancellRequestAction.perform">
							<input type="hidden" name="id"
								value="${notPayedCarRequest.getID()}" /> <input type="hidden"
								name="carID" value="${car.getID()}"> <input type="text"
								size="20" value="cancellation purpose"
								name="cancellationPurpose"> <input type="submit"
								name="cancell" value="cancell">
						</form></td>
				</tr>
			</c:forEach>
		</table>
	</fieldset>
	<br>
	<br>
	<fieldset>
		<legend>
			<b>Cancelled car requests</b>
		</legend>
		<table border="below" cellpadding="10" cellspacing="0" width="100%">
			<tr>
				<th align="center">User Name</th>
				<th align="center">Name</th>
				<th align="center">Passport</th>
				<th align="center">Car</th>
				<th align="center">Rent Duration</th>
				<th align="center">Cancellation Purpose</th>
				<th align="center">Action</th>
			</tr>
			<c:forEach items="${cancelledCarRequests}" var="cancelledCarRequest">
				<c:set var="car" value="${cancelledCarRequest.getCar()}" />
				<c:set var="user" value="${cancelledCarRequest.getUser()}" />
				<tr>
					<td align="center"><c:out value="${user.getLogin()}" /></td>
					<td align="center"><c:out
							value="${cancelledCarRequest.getName()}" /></td>
					<td align="center"><c:out
							value="${cancelledCarRequest.getPassport()}" /></td>
					<td align="center"><c:out
							value="${car.getManufacturer()} ${car.getModel()} ${car.getNumber()}" /></td>
					<td align="center"><c:out
							value="${cancelledCarRequest.getRentDuration()}" /></td>
					<td align="center"><c:out
							value="${cancelledCarRequest.getCancellationPurpose()}" /></td>
					<td align="center">

						<form method="post" action="deleteCarRequestAction.perform">
							<input type="hidden" name="id"
								value="${cancelledCarRequest.getID()}"> <input
								type="submit" name="delete" value="delete">
						</form>
				</tr>
			</c:forEach>
		</table>
	</fieldset>
	<br>
	<br>
	<fieldset>
		<legend>
			<b>Payed Requests</b>
		</legend>
		<table border="below" cellpadding="10" cellspacing="0" width="100%">
			<tr>
				<th align="center">User Name</th>
				<th align="center">Name</th>
				<th align="center">Passport</th>
				<th align="center">Car</th>
				<th align="center">Rent duration</th>
				<th colspan="2" align="center">Action</th>
			</tr>
			<c:forEach items="${payedCarRequests}" var="payedCarRequest">
				<c:set var="car" value="${payedCarRequest.getCar()}" />
				<c:set var="user" value="${payedCarRequest.getUser()}" />
				<tr>
					<td align="center"><c:out value="${user.getLogin()}" /></td>
					<td align="center"><c:out value="${payedCarRequest.getName()}" /></td>
					<td align="center"><c:out
							value="${payedCarRequest.getPassport()}" /></td>
					<td align="center"><c:out
							value="${car.getManufacturer()} ${car.getModel()} ${car.getNumber()}" /></td>
					<td align="center"><c:out
							value="${payedCarRequest.getRentDuration()}" /></td>
					<td align="center">
						<form method="post" action="closeRequestAction.perform">
							<input type="hidden" name="id" value="${payedCarRequest.getID()}"><input
								type="hidden" name="carID" value="${car.getID()}"><input
								type="submit" name="Close the " value="Car back">
						</form>
					</td>
					<td align="center"><form method="post"
							action="makeBillAction.perform">
							<input type="hidden" name="id" value="${payedCarRequest.getID()}" />
							<input type="hidden" name="carID" value="${car.getID()}">
							<input type="text" size="20" value="bill purpose"
								name="billPurpose"> <input type="submit" name="bill"
								value="Make a bill">
						</form></td>

				</tr>
			</c:forEach>
		</table>
	</fieldset>
</body>

</html>